var wsUri = "ws://" + document.location.host + "/dots-and-boxes/" + "chatws";
var wschat = new WebSocket(wsUri);

function enviarTexto() {

    var msg = document.getElementById("form:msg").value;

    var jInfos = {
        msg: msg
    };

    var info = JSON.stringify(jInfos);

    document.getElementById("form:msg").value = "";

    wschat.send(info);
}

wschat.onmessage = function (evt) {
    onMessageChat(evt);
};
function onMessageChat(evt) {

    var json = JSON.parse(evt.data);

    var p = document.createElement('p');
    p.innerHTML = "- " + json.autor + ": " + json.msg;
    document.getElementById("conversas").appendChild(p);
}


